/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jmodcog2.filter;

import jmodcog2.base.BaseConfig;

/**
 *
 * @author Mitch
 */
public abstract class PixelFilter extends Filter {

    protected final float[] contrast = new float[1];

    public PixelFilter(int size) {
        super(new PixelFilterConfig(size));
    }

    @Override
    protected void _run(int mode) {
        int i = getGlobalId();
        if (i < input_size) {
            output[i] = _f(input[i]);
        }
    }

    protected abstract float _f(float x);

    @Override
    public float[] getOutput() {
        get(output);
        return output;
    }

    @Override
    public boolean process(float[] input) {
        if (input_size == input.length) {
            System.arraycopy(input, 0, this.input, 0, input_size);
            put(this.input);
            execute(input_size);
            return true;
        }
        return true;
    }

    static class PixelFilterConfig implements BaseConfig {

        int size;

        public PixelFilterConfig(int size) {
            this.size = size;
        }

        @Override
        public int getInputSize() {
            return size;
        }

        @Override
        public int getOutputSize() {
            return size;
        }
    }
}
